#import "CTSexCell.h"
@implementation CTSexCell
- (void)initialize
{
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.maleButton];
    [self.contentView addSubview:self.femaleButton];
    CGFloat width = (self.ct_width - Ratio(52))*0.5;
    [self.maleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Ratio(16));
        make.top.mas_equalTo(Ratio(10));
        make.bottom.mas_equalTo(self.contentView);
        make.width.mas_equalTo(width);
    }];
    [self.femaleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.maleButton.mas_right).offset(Ratio(20));
        make.right.mas_equalTo(Ratio(-16));
        make.top.mas_equalTo(Ratio(10));
        make.bottom.mas_equalTo(self.contentView);
        make.width.mas_equalTo(self.maleButton.mas_width);
    }];
}
- (BYButton *)maleButton {
    if (!_maleButton) {
        _maleButton = [[BYButton alloc] initWithFrame:CGRectZero iconNameNor:@"login_unsel" iconNameSel:@"login_sel" text:@"Male" font:kFontSize(14) textColorNor:[UIColor color30323E] textColorSel:[UIColor color30323E] style:ButtonLayoutStyleReversal inset:Ratio(12) space:0 isAnimated:NO];
        _maleButton.layer.masksToBounds = YES;
        _maleButton.layer.cornerRadius = Ratio(12);
        _maleButton.layer.borderWidth = 1;
        _maleButton.layer.borderColor = [UIColor colorWithHexString:@"#AFBACA"].CGColor;
        __weak typeof(self) weakself = self;
        _maleButton.clickBlock = ^{
            if (weakself.selectBlock) {
                weakself.selectBlock(_maleButton.textLabel.text);
            }
            weakself.femaleButton.isSelected = NO;
            weakself.maleButton.isSelected = YES;
        };
    }
    return _maleButton;
}
- (BYButton *)femaleButton {
    if (!_femaleButton) {
        _femaleButton = [[BYButton alloc] initWithFrame:CGRectZero iconNameNor:@"login_unsel" iconNameSel:@"login_sel" text:@"Female" font:kFontSize(14) textColorNor:[UIColor color30323E] textColorSel:[UIColor color30323E] style:ButtonLayoutStyleReversal inset:Ratio(12) space:0 isAnimated:NO];
        _femaleButton.layer.masksToBounds = YES;
        _femaleButton.layer.cornerRadius = Ratio(12);
        _femaleButton.layer.borderWidth = 1;
        _femaleButton.layer.borderColor = [UIColor colorWithHexString:@"#AFBACA"].CGColor;
        __weak typeof(self) weakself = self;
        _femaleButton.clickBlock = ^{
            if (weakself.selectBlock) {
                weakself.selectBlock(_maleButton.textLabel.text);
            }
            weakself.maleButton.isSelected = NO;
            weakself.femaleButton.isSelected = YES;
        };
    }
    return _femaleButton;
}
- (void)setGender:(NSString *)gender {
    _gender = gender;
    if ([gender isEqualToString:@"Male"]) {
        self.maleButton.isSelected = YES;
        self.femaleButton.isSelected = NO;
        NSDictionary *data = @{
            @"navigationRoute" : NSStringFromClass(self.class),
            @"pageIdentity" : kct_btn_idcard_male,
            @"elementUniqueIdentifier"  : kct_btn_idcard_male,
        };
        [CTUploadManager ct_uploadType:CTUploadTypeBTN data:data];
    } else if ([gender isEqualToString:@"Male"]) {
        self.maleButton.isSelected = NO;
        self.femaleButton.isSelected = YES;
        NSDictionary *data = @{
            @"navigationRoute" : NSStringFromClass(self.class),
            @"pageIdentity" : kct_btn_idcard_female,
            @"elementUniqueIdentifier"  : kct_btn_idcard_female,
        };
        [CTUploadManager ct_uploadType:CTUploadTypeBTN data:data];
    } else {
        self.maleButton.isSelected = NO;
        self.femaleButton.isSelected = NO;
    }
}
@end
